export default {
    gainFormData: function (object) {
        let params = new FormData();

        for (const key in object) {
            const element = object[key];
            params.set(key, element);
        }

        return params;
    },
    // 浏览器环境
    gainEnvironment: function () {
        var inBrowser = typeof window !== 'undefined';
        var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
        var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
        var UA = inBrowser && window.navigator.userAgent.toLowerCase();
        var isIE = UA && /msie|trident/.test(UA);
        var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
        var isEdge = UA && UA.indexOf('edge/') > 0;
        var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
        var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
        var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
        var isPhantomJS = UA && /phantomjs/.test(UA);
        var isFF = UA && UA.match(/firefox\/(\d+)/);

        var env = "";
        if (isIE) {
            env = '当前环境为IE'
            console.log(env);
        } else if (isIE9) {
            env = '当前环境为IE9'
            console.log(env);
        } else if (isEdge) {
            env = '当前环境为Edge'
            console.log(env);
        } else if (isAndroid) {
            env = '当前环境为安卓'
            console.log(env);
        } else if (isIOS) {
            env = '当前环境为IOS'
            console.log(env);
        } else if (isChrome) {
            env = '当前环境为谷歌'
            console.log(env);
        } else if (isPhantomJS) {
            env = '当前环境为phantomjs'
            console.log(env);
        } else if (isFF) {
            env = '当前环境为火狐'
            console.log(env);
        }
    },
    getTime: function () {
        let date = new Date();

        var fullYear = date.getFullYear();

        var month = date.getMonth() + 1;

        var _date = date.getDate();

        var hours = date.getHours();

        var minutes = date.getMinutes();

        var seconds = date.getSeconds();

        if (month < 10) { month = '0' + month }

        if (_date < 10) { _date = '0' + _date }

        if (hours < 10) { hours = '0' + hours }

        if (minutes < 10) { minutes = '0' + minutes }

        if (seconds < 10) { seconds = '0' + seconds }

        // let Str = fullYear + '-' + month + '-' + _date + ' ' + hours + ':' + minutes + ':' + seconds
        let Str = fullYear + '-' + month + '-' + _date

        return Str
    }
}